﻿using System;
using System.Web;
using Framework.Library.Core.Config;
using Framework.Library.Core.Utils.Web;

namespace Framework.Library.Core.Utils.GlobalHelper
{
    public class RedirectHelper
    {        
        public static void ErrorRedirect(Exception objErr)
        {
            HttpContext context = HttpContext.Current;
            if (objErr != null)
            {
                context.Session["objErr"] = objErr;
                context.Session["objUrl"] = context.Request.Url.AbsoluteUri;
            }
            context.Response.Redirect(Configurations.ROOTDIR + "Error.aspx", true);
            //ResponseUtils.PermanentRedirect(HttpContext.Current.Response, cfg.RootDir.value + "Error.aspx");
        }

        public static void ErrorRedirect(string exMessage)
        {
            ErrorRedirect(new Exception(exMessage));
        }

        public static void LoginRedirect(string returnUrl)
        {
            ResponseUtils.PermanentRedirect(HttpContext.Current.Response,
                                            Configurations.ROOTDIR + "Login.aspx?returnurl=" + returnUrl);
        }
    }
}